package com.wlient.basic.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;
import java.util.Arrays;

/**
 * 用户枚举
 *
 * @author 史炜立
 * @date 2022/03/14
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Component
public enum UserEnum {

    select("1", "select"){
        @Override
        public boolean UserStatus() {
            return true;
        }
    },
    update("2", "update"){
        @Override
        public boolean UserStatus() {
            return true;
        }
    },
    delete("3", "delete"){
        @Override
        public boolean UserStatus() {
            return true;
        }
    };

    private String id;

    private String type;

    public static UserEnum of(String type) throws Exception {
      return  Arrays.stream(UserEnum.values())
                .filter(item -> item.getType().equals(type))
                .findFirst()
                .orElseThrow(() -> new Exception("非法的字典类型"));
    }
    /**
     * 	抽象方法：发货
     * @return
     */
    public abstract boolean  UserStatus();

}
